package com.gxa.order.controller.hotel;

import com.gxa.common.commons.R;
import com.gxa.order.pojo.hotel.Tenant;
import com.gxa.order.service.TenantService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.time.LocalDate;

@RestController
@RequestMapping(value = "/tenant")
public class TenantController {
    @Resource
    private TenantService tenantService;
    private R r;
    /**
     * 添加住客
     * @param tenant
     * @return
     */
    @PostMapping(value = "/addTenant")
    public R addTenant(@RequestBody Tenant tenant){
        return tenantService.addTenant(tenant);
    }

    /**
     * 查询住客信息
     * @param hotelOrderId
     * @return
     */
    @GetMapping(value = "/queryTenant")
    public  R queryTenant(Integer hotelOrderId){
        List<Tenant> tenants = tenantService.queryTenant(hotelOrderId);
        r.setCode(200);
        r.setData(tenants);
        return r;
    }

    /**
     * 修改住客
     * @param tenant
     * @return
     */
    @PostMapping(value = "/updateTenant")
    public R updateTenant(@RequestBody Tenant tenant){
        return tenantService.updateTenant(tenant);
    }

    /**
     * 删除住客
     * @param hotelOrderId
     * @return
     */
    @GetMapping(value = "/delTenant")
    public R delTenant(Integer hotelOrderId){
        return tenantService.delTenant(hotelOrderId);
    }
}
